<?php 

namespace App\Repositories;
use Carbon\Carbon;

class LanCompleteRepository extends Repository 
{
    public function model() 
    {
        return 'App\Models\LanComplete';
    }

    public function multiCreate($order_id, $languages)
    {
        if (!empty($languages)) {
            $data = [];
            foreach ($languages as $key => $value) {
                array_push($data, [
                    'order_id'=> $order_id, 
                    'language'=> $value, 
                    'progress'=> 0,
                    'created_at' => Carbon::now(),
                    'updated_at' => Carbon::now()
                ]);
            }

            return $this->model->insert($data);
        }

        return false;
    }

    // 根据订单ID得到语言版本列表
    public function getLanguageByOrder($orderId)
    {
        return $this->model->where('order_id', $orderId)->lists('language');
    }
}